<?php
	$action = "pel/addlang";
	$newlang = "";
	$langtravel="";
	$langtraining="";
	$langtraveldate="";
	$langtrainingdate="";
	$langmedia="";
	$langcertificat="";
	$langorganisme="";
	$langnote="";
	$langdate="";
	$access_id = 0;
	$image=$vars['url'] . "/mod/pel/graphics/icon_customise_info.gif";
	$moins="<img src=\"".$vars['url']."/mod/pel/graphics/moins.gif"."\" alt=\"moins\"/>";
	$plus="<img src=\"".$vars['url'] . "/mod/pel/graphics/plus.gif"."\"alt=\"plus\"/>Ajouter un champ";

  $title_label = elgg_echo('pel:otherlang');
  $autoEval = elgg_echo('pel:autoeval');
  $bio = elgg_echo('pel:bio');
  $dir = elgg_echo('pel:dir');
  $pays = elgg_echo('pel:pays');
  $travel = elgg_echo('pel:travel');
  $training = elgg_echo('pel:training');
  $media = elgg_echo('pel:media');
  $tab_intitule=elgg_echo('pel:intitule');
 
 // $file = elgg_echo('pel:file');
  $certificat = elgg_echo('pel:certificat');
  $nom = elgg_echo('pel:nom');
  $organisme = elgg_echo('pel:organisme');
  $note = elgg_echo('pel:note');
  $date= elgg_echo('pel:date');
  $ecouter=elgg_echo('pel:ecouter');
  $lire=elgg_echo('pel:lire');
  $conversation=elgg_echo('pel:conversation');
  $exprimer= elgg_echo('pel:exprimer');
  $ecrire= elgg_echo('pel:ecrire');
  $parler=elgg_echo('pel:parler');
  $comprendre=elgg_echo('pel:comprendre');
  $tabecouterA1=elgg_echo('pel:tabecouterA1');
  $tabecouterA2=elgg_echo('pel:tabecouterA2');
  $tabecouterB1=elgg_echo('pel:tabecouterB1');
  $tabecouterB2=elgg_echo('pel:tabecouterB2');
  $tabecouterC1=elgg_echo('pel:tabecouterC1');
  $tabecouterC2=elgg_echo('pel:tabecouterC2');
  $tablireA1=elgg_echo('pel:tablireA1');
  $tablireA2=elgg_echo('pel:tablireA2');
  $tablireB1=elgg_echo('pel:tablireB1');
  $tablireB2=elgg_echo('pel:tabelireB2');
  $tablireC1=elgg_echo('pel:tablireC1');
  $tablireC2=elgg_echo('pel:tablireC2');
  $tabconversationA1=elgg_echo('pel:tabconversationA1');
  $tabconversationA2=elgg_echo('pel:tabconversationA2');
  $tabconversationB1=elgg_echo('pel:tabconversationB1');
  $tabconversationB2=elgg_echo('pel:tabconversationB2');
  $tabconversationC1=elgg_echo('pel:tabconversationC1');
  $tabconversationC2=elgg_echo('pel:tabconversationC2');
  $tabexprimerA1=elgg_echo('pel:tabexprimerA1');
  $tabexprimerA2=elgg_echo('pel:tabexprimerA2');
  $tabexprimerB1=elgg_echo('pel:tabexprimerB1');
  $tabexprimerB2=elgg_echo('pel:tabexprimerB2');
  $tabexprimerC1=elgg_echo('pel:tabexprimerC1');
  $tabexprimerC2=elgg_echo('pel:tabexprimerC2');
  $tabecrireA1=elgg_echo('pel:tabecrireA1');
  $tabecrireA2=elgg_echo('pel:tabecrireA2');
  $tabecrireB1=elgg_echo('pel:tabecrireB1');
  $tabecrireB2=elgg_echo('pel:tabecrireB2');
  $tabecrireC1=elgg_echo('pel:tabecrireC1');
  $tabecrireC2=elgg_echo('pel:tabecrireC2');

  $title_textbox = elgg_view('input/text', array('internalname' => 'pellang', 'value' => $newlang));
  $travel_textbox = elgg_view('input/text', array('internalname' => 'langtravel_0', 'value' => $langtravel));
  $training_textbox = elgg_view('input/text', array('internalname' => 'langtraining_0', 'value' => $langtraining));
  $traveldate_textbox = elgg_view('input/text', array('internalname' => 'langtraveldate_0', 'value' => $langtraveldate));
  $trainingdate_textbox = elgg_view('input/text', array('internalname' => 'langtrainingdate_0', 'value' => $langtrainingdate));
  
  $media_textbox = elgg_view('input/longtext', array('internalname' => 'langmedia', 'value' => $langmedia));
  $certificat_textbox = elgg_view('input/text', array('internalname' => 'langcertificat_0', 'value' => $langcertificat));
  $organisme_textbox = elgg_view('input/text', array('internalname' => 'langorganisme_0', 'value' => $langorganisme));
  $note_textbox = elgg_view('input/text', array('internalname' => 'langnote_0', 'value' => $langnote));
  $date_textbox = elgg_view('input/text', array('internalname' => 'langdate_0', 'value' => $langdate));
  
  $ecouterA1= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'A1')));
  $ecouterA2= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'A2')));
  $ecouterB1= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'B1')));
  $ecouterB2= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'B2')));
  $ecouterC1= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'C1')));
  $ecouterC2= elgg_view('input/radio',array('internalname' => 'ecouter', 'options' => array('' => 'C2')));
  
  $lireA1= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'A1')));
  $lireA2= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'A2')));
  $lireB1= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'B1')));
  $lireB2= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'B2')));
  $lireC1= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'C1')));
  $lireC2= elgg_view('input/radio',array('internalname' => 'lire', 'options' => array('' => 'C2')));
  
  $conversationA1= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'A1')));
  $conversationA2= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'A2')));
  $conversationB1= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'B1')));
  $conversationB2= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'B2')));
  $conversationC1= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'C1')));
  $conversationC2= elgg_view('input/radio',array('internalname' => 'conversation', 'options' => array('' => 'C2')));
  
  $exprimerA1= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'A1')));
  $exprimerA2= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'A2')));
  $exprimerB1= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'B1')));
  $exprimerB2= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'B2')));
  $exprimerC1= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'C1')));
  $exprimerC2= elgg_view('input/radio',array('internalname' => 'exprimer', 'options' => array('' => 'C2')));

  $ecrireA1= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'A1')));
  $ecrireA2= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'A2')));
  $ecrireB1= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'B1')));
  $ecrireB2= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'B2')));
  $ecrireC1= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'C1')));
  $ecrireC2= elgg_view('input/radio',array('internalname' => 'ecrire', 'options' => array('' => 'C2')));


//  $file_upload = elgg_view('input/file', array('internalname' => 'file_upload'));
  $access_input = elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id));
  $access_label = elgg_echo('pel:acces');
  $submit_input = elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('Enregistrer')));

  if (isset($vars['entity'])){
    $entity_hidden = elgg_view('input/hidden', array('internalname' => 'post', 'value' => $vars['entity']->getGUID()));
  } 
	else{
    $entity_hidden = '';
  }
  $url = $vars['url'];
  $form_body = <<<EOT
  	<p>
			<label>$title_label</label><br />
      $title_textbox
  	</p>
    <div id="example" class="flora ui-tabs-nav">
	    <ul id="pel_menu">
        <li><a href="#fragment-1"><span>$autoEval</span></a></li>
        <li><a href="#fragment-2"><span>$bio</span></a></li>
        <li><a href="#fragment-3"><span>$dir</span></a></li>
	    </ul>
        <div id="fragment-1">
          <table id="pel">
          <tr>
            <tr><td><h3>$comprendre</h3></td></tr>
            <th scope="col">&nbsp;</th>
            <th scope="col">A1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">A2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C2</th>
            <th scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th scope="row"><img src="$url/mod/pel/graphics/ecouter.gif" alt="ecouter"/> $ecouter</th>
            <td>
              $ecouterA1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterA1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecouterA2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterA2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecouterB1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterB1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecouterB2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterB2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecouterC1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterC1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecouterC2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecouterC2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
          </tr>
          <tr>
            <th scope="row"><img src="$url/mod/pel/graphics/lire.gif" alt="lire" /> $lire</th>
            <td>
              $lireA1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tablireA1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $lireA2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tablireA2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $lireB1
            </td>
            <td>
           		<a href="#" class="tooltip" title="$tablireB1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $lireB2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tablireB2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $lireC1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tablireC1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $lireC2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tablireC2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
          </tr>
          <tr><td>&nbsp;</td></tr>
          <tr><td><h3>$parler</h3></td></tr>
          <tr>
            <th scope="col">&nbsp;</th>
            <th scope="col">A1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">A2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C2</th>
            <th scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th scope="row"><img src="$url/mod/pel/graphics/ppconv.gif"  alt="conversation"/> $conversation</th>
            <td>
              $conversationA1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationA1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $conversationA2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationA2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $conversationB1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationB1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $conversationB2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationB2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $conversationC1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationC1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $conversationC2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabconversationC2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
          </tr>
          <tr>
            <th scope="row"><img src="$url/mod/pel/graphics/exp_oral_continu.gif"  alt="exprimer"/> $exprimer</th>
            <td>
              $exprimerA1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerA1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $exprimerA2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerA2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $exprimerB1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerB1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $exprimerB2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerB2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $exprimerC1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerC1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $exprimerC2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabexprimerC2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
          </tr>
            <tr><td>&nbsp;</td></tr>
            <tr><td><h3>$ecrire</h3></td></tr>
          <tr>
            <th scope="col">&nbsp;</th>
            <th scope="col">A1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">A2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">B2</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C1</th>
            <th scope="col">&nbsp;</th>
            <th scope="col">C2</th>
            <th scope="col">&nbsp;</th>
          </tr>
          <tr>
            <th scope="row"><img src="$url/mod/pel/graphics/ecrire.gif"  alt="ecrire"/> $ecrire</th>
          <td>
              $ecrireA1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecrireA1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecrireA2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecrireA2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecrireB1
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecrireB1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecrireB2
            </td>
            <td>
            	<a href="#" class="tooltip" title="$tabecrireB2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecrireC1
            </td><td>
            	<a href="#" class="tooltip" title="$tabecrireC1"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
            <td>
              $ecrireC2
            </td><td>
            	<a href="#" class="tooltip" title="$tabecrireC2"><img src="$image" width="14px" height="14px" alt=""/></a>
            </td>
          </tr>
        </table>
        </div>
        <div id="fragment-2">
        <table class="contenu">
        <tr><td>
            <h4>$travel</h4>
            <table id="tableToAppend2">
            <th class="grand">$pays</th>
            <th class="petit">$date</th>
            <th></th>
            <tr>
            <td>
            $travel_textbox
            </td><td>
            $traveldate_textbox
            <input type="hidden" name="champsSupTravel[0]" value="0" />
            </td><td></td></tr>
          </table>
          <a href="#" id="plustravel">$plus</a>
<script  type="text/javascript">
  $(document).ready(function(){
    var i = 1;
    $("a#plustravel").click(function(e){                                                                                                                                                                
      $("#tableToAppend2").append('<tr id="row_'+ i +'"><td><input name="langtravel_' + i + '" value="" class="input-text" type="text"></td><td><input name="langtraveldate_' + i + '" value="" class="input-text" type="text"></td><td><input type="hidden" name="champsSupTravel['+i+']" value="'+ i +'" /><a href="javascript:checkMoins2('+i+')" id="moinstravel" id="'+ i +'">$moins</a></td></tr>');
      i++;
    })
    checkMoins2 = function(i){
      $("#row_" + i).remove();
      i--;
    }
  });
</script>
          </td></tr>
          <tr><td>
          <h4>$training</h4>
          <table id="tableToAppend3">
          <th class="grand">$tab_intitule</th>
          <th class="petit">$date</th>
          <th></th>
          <tr><td>
          $training_textbox
          </td><td>
          $trainingdate_textbox
          <input type="hidden" name="champsSupTraining[0]" value="0" />
          </td><td></td>
          </tr>
        </table>
        <a href="#" id="plustraining">$plus</a>
<script  type="text/javascript">
  $(document).ready(function(){
    var i = 1;
    $("a#plustraining").click(function(e){                                                                                                                                                                
      $("#tableToAppend3").append('<tr id="row_'+ i +'"><td><input name="langtraining_' + i + '" value="" class="input-text" type="text"></td><td><input name="langtrainingdate_' + i + '" value="" class="input-text" type="text"></td><td><input type="hidden" name="champsSupTraining['+i+']" value="'+ i +'" /><a href="javascript:checkMoins3('+i+')" id="moinstraining" id="'+ i +'"$moins</a></td></tr>');
      i++;
    })
    checkMoins3 = function(i){
      $("#row_" + i).remove();
      i--;
    }
  });
</script>
          </td></tr>
          <tr><td>
            <h4>$media</h4>
            $media_textbox
          </td></tr>
          </table>
        </div>
        <div id="fragment-3">
          <h4>$certificat</h4>
          <table id="tableToAppend">
            <th class="grand">$nom</th>
            <th class="grand">$organisme</th>
            <th class="petit">$note</th>
            <th class="petit">$date</th>
            <th>&nbsp;</th>
            <tr>
              <td>$certificat_textbox</td>
              <td>$organisme_textbox</td>
              <td>$note_textbox</td>
              <td>$date_textbox
              <input type="hidden" name="champsSup[0]" value="0" />
              </td>
              <td>&nbsp;&nbsp;</td>
            </tr>
        </table>
        <a href="#" id="plus">$plus</a>
<script  type="text/javascript">
  $(document).ready(function(){
    var i = 1;
    $("a#plus").click(function(e){                                                                                                                                                                
      $("#tableToAppend").append('<tr id="row_'+ i +'"><td><input name="langcertificat_' + i + '" value="" class="input-text" type="text"></td><td><input name="langorganisme_' + i + '" value="" class="input-text" type="text"></td><td><input name="langnote_' + i + '" value="" class="input-text" type="text"></td><td><input name="langdate_' + i + '" value="" class="input-text" type="text"> </td><td><input type="hidden" name="champsSup['+i+']" value="'+ i +'" /><a href="javascript:checkMoins('+i+')" id="moins" id="'+ i +'">$moins</a></td></tr>');
      i++;
    })
    checkMoins = function(i){
      $("#row_" + i).remove();
      i--;
    }
  });
</script>
	        </div>
	    </div>
	<p>
  	$access_label
    $access_input
		$entity_hidden
		$submit_input
	</p>
EOT;

  echo elgg_view('input/form', array(	'action' => "{$vars['url']}action/$action",
 																					'body' => $form_body
                                          //,'enctype' => "multipart/form-data"
                                          ));
?>